<template>
  <div>
    <el-container>
      <el-header> 
        <HeaderPage :avatar="avatar" :nick_name="nick_name" :is_admin="isAdmin"></HeaderPage>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-scrollbar height="500px">
            <el-menu
                
                class="el-menu-vertical-demo"
                @select="handleSelect"
                >
                <el-menu-item index="review">
                  <router-link style="text-decoration:none" :to="{name:'Review'}"><span>词条管理</span></router-link> 
                </el-menu-item>

                <el-menu-item index="financial">
                <router-link style="text-decoration:none" :to="{name:'Financial'}"><span>财务</span></router-link> 
              </el-menu-item>

            </el-menu>
          </el-scrollbar>
        </el-aside>
        <el-main>
           <router-view :key="randomID"></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
 
  <FooterPage></FooterPage>
</template>

<script>
import HeaderPage from '@/components/HeaderPage.vue'
import FooterPage from '@/components/FooterPage.vue'
import config from '../../spoken.config.json'
import { ElNotification } from 'element-plus'
import {JSEncrypt} from 'jsencrypt'

export default {
  name: 'ConsolePage',
  props: {
    msg: String
  },
  components:{
    HeaderPage,
    FooterPage,
  },

  data(){
    return{
      
      isAdmin:false,
      
      nick_name:null,
      user_id:null,
      avatar:null,
      
      randomID:Date.now(),
    }
  },

  created(){
    this.user_profiles();
  },

  watch:{
    
  },

  methods:{
    //页面初始化
    async user_profiles(){
                //读cookie，获取用户token
                const login_token= this.$commonFunctions.get_cookies('login_token')
                console.log("Console页面初始化数据。login_token："+login_token);
             
                const user_profiles= await this.$commonFunctions.get_user_profiles(login_token);
              
                this.nick_name=user_profiles.name
                this.avatar=user_profiles.avatar
                this.user_id=user_profiles.user_id
                this.isAdmin=user_profiles.is_superuser

                //把昵称和头像信息存到cookie里
                
                console.log("Dictionary页面初始化数据。用户名："+this.nick_name+" 头像地址："+this.avatar+" 管理员标识："+user_profiles.is_superuser);
             },
             
    handleSelect(event){
      console.log(event)
      if(event==='review'){
        this.$router.push("review")
      }else if(event==='financial'){
        this.$router.push("financial")
      }
    }
  },
 
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
router-link{
  text-decoration:none;}

</style>
